LISTBOX_MIMETYPE = "application/x-item"

OP_NODE_INPUT = 1
OP_NODE_OUTPUT = 2
OP_NODE_ADD = 3
OP_NODE_SUB = 4
OP_NODE_MUL = 5
OP_NODE_DIV = 6

OP_NODE_Demo = 7
OP_NODE_SHUCHU = 8
OP_NODE_CUSTOM = 9
OP_NODE_APPEND = 10
OP_NODE_IMAGE_CLICK = 11
OP_NODE_IMAGE_CLICK2 = 12
OP_NODE_HWND = 13
OP_NODE_ONE = 14
OP_NODE_Frequency = 15
OP_NODE_Time = 16
OP_NODE_Switch = 17
OP_NODE_NoIMAGE_CLICK = 18
OP_NODE_CLICK = 19
OP_NODE_IMAGE = 20
OP_NODE_ChongDingXiang = 21


CALC_NODES = {
}


class ConfException(Exception): pass
class InvalidNodeRegistration(ConfException): pass
class OpCodeNotRegistered(ConfException): pass


def register_node_now(op_code, class_reference):
    if op_code in CALC_NODES:
        raise InvalidNodeRegistration("Duplicate node registration of '%s'. There is already %s" %(
            op_code, CALC_NODES[op_code]
        ))
    CALC_NODES[op_code] = class_reference


def register_node(op_code):
    def decorator(original_class):
        register_node_now(op_code, original_class)
        return original_class
    return decorator

def get_class_from_opcode(op_code):
    if op_code not in CALC_NODES: raise OpCodeNotRegistered("OpCode '%d' is not registered" % op_code)
    return CALC_NODES[op_code]



# import all nodes and register them
#from examples.example_calculator.nodes import *
#from nodes import *#--
import sys
import os

_path = ''
_path = sys.argv[0]
_path = os.path.dirname(_path)
if _path[-8:] == 'SeerMain':
    _path = str(_path[0:-8])
sys.path.append(_path + '\\List\\SeerNode\\examples\\example_calculator\\nodes')#Yoso路径
sys.path.append('./examples/example_calculator/nodes')#当前相对路径

__import__('examples.example_calculator.nodes.input',fromlist=["*"])

__import__('examples.example_calculator.nodes.custom',fromlist=["*"])
__import__('examples.example_calculator.nodes.imageClick',fromlist=["*"])
__import__('examples.example_calculator.nodes.imageClick2',fromlist=["*"])
__import__('examples.example_calculator.nodes.shuchu',fromlist=["*"])
__import__('examples.example_calculator.nodes.append',fromlist=["*"])
__import__('examples.example_calculator.nodes.hwnd',fromlist=["*"])
__import__('examples.example_calculator.nodes.yici',fromlist=["*"])
__import__('examples.example_calculator.nodes.frequency',fromlist=["*"])
__import__('examples.example_calculator.nodes.timeSleep',fromlist=["*"])
__import__('examples.example_calculator.nodes.switch',fromlist=["*"])
__import__('examples.example_calculator.nodes.imageClick3',fromlist=["*"])
__import__('examples.example_calculator.nodes.Click',fromlist=["*"])
__import__('examples.example_calculator.nodes.image',fromlist=["*"])
__import__('examples.example_calculator.nodes.ChongDingXiang',fromlist=["*"])